package com.shanzmoo.platform.manage.api.util;

import com.shanzmoo.base.bean.BaseRedisKeyUtils;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * redis key 操作工具类
 *
 * @author： Gzhao 2021/4/3
 */
public class RedisKeyUtils extends BaseRedisKeyUtils {

    private final static String SECOND_LEVEL = "api:pma:";

    private RedisKeyUtils(){}

    protected static String installKey(String... strList) {
        List<String> list = new ArrayList<>();
        list.add(SECOND_LEVEL);
        list.addAll(Arrays.asList(strList));

        return installBaseKey(list);
    }

    /**
     * 组装用户 jwt 令牌 key
     * @param subject
     * @return
     */
    public static String installSubectJwtKey(String subject) {
        return installKey(KeyPrefix.JWT, subject);
    }

    private static class KeyPrefix{
        /**
         * JWT 在 Redis 中保存的key前缀
         */
        private static String JWT = "auth_jwt:";
    }

}
